<?php
namespace Home\Widget;
use Think\Controller;
class WgWidget extends Controller {

    public function nav(){
        $nav = M('ArticleCate')->where(array('is_home'=>1,'status'=>1))->order('ordid desc,id desc')->select();

        $this->assign('nav',$nav);
        $this->display('Widget:nav');
    }

    public function side_bar(){
        //最新活动
        $active = D('Article')->field('id,title,intro,img,url')->where(array('cate_id'=>18))->order('ordid desc,id desc')->find();

        //项目
        $cate_id = 16;
        if ($cate_id) {
            $id_arr = D('ArticleCate')->get_child_ids($cate_id, true);
            $map['cate_id'] = array('IN', $id_arr);
        }
        $item = D('Article')->field('id,title,intro,img,cate_id')->order('ordid desc,add_time desc')->find();

        $this->assign('active',$active);
        $this->assign('item',$item);

        $this->display('Widget:side_bar');
    }

    //友情链接
    public function flink(){
        $Flink = D('Flink');
        $map = array('cate_id'=>1);
        $flink_list = $Flink->where($map)->order('ordid desc')->select();
        $this->assign('flink_list',$flink_list);
        $this->display('Widget:flink');
    }

}